<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP, DeriveDataTypeable #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- Module      : Data.Text.Encoding.Error</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Copyright   : (c) Bryan O'Sullivan 2009</span><span>
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Portability : GHC</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Types and functions for dealing with encoding and decoding errors</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- in Unicode text.</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- The standard functions for encoding and decoding text are strict,</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- which is to say that they throw exceptions on invalid input.  This</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- is often unhelpful on real world input, so alternative functions</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- exist that accept custom handlers for dealing with invalid inputs.</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- These 'OnError' handlers are normal Haskell functions.  You can use</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- one of the presupplied functions in this module, or you can write a</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- custom handler of your own.</span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Encoding.Error</span><span>
</span><span id="line-23"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-24"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Error handling types</span></span><span>
</span><span id="line-25"></span><span>      </span><span class="annot"><a href="Data.Text.Encoding.Error.html#UnicodeException"><span class="hs-identifier">UnicodeException</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnError"><span class="hs-identifier">OnError</span></a></span><span>
</span><span id="line-27"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier">OnDecodeError</span></a></span><span>
</span><span id="line-28"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnEncodeError"><span class="hs-identifier">OnEncodeError</span></a></span><span>
</span><span id="line-29"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Useful error handling functions</span></span><span>
</span><span id="line-30"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#lenientDecode"><span class="hs-identifier">lenientDecode</span></a></span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier">strictDecode</span></a></span><span>
</span><span id="line-32"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#strictEncode"><span class="hs-identifier">strictEncode</span></a></span><span>
</span><span id="line-33"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#ignore"><span class="hs-identifier">ignore</span></a></span><span>
</span><span id="line-34"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#replace"><span class="hs-identifier">replace</span></a></span><span>
</span><span id="line-35"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#"><span class="hs-identifier">Control.DeepSeq</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#NFData"><span class="hs-identifier">NFData</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#Exception"><span class="hs-identifier">Exception</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exception.html#throw"><span class="hs-identifier">throw</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.html#"><span class="hs-identifier">Data.Typeable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier">Typeable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Word.html#"><span class="hs-identifier">Data.Word</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Numeric.html#"><span class="hs-identifier">Numeric</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Numeric.html#showHex"><span class="hs-identifier">showHex</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span class="hs-comment">-- | Function type for handling a coding error.  It is supplied with</span><span>
</span><span id="line-44"></span><span class="hs-comment">-- two inputs:</span><span>
</span><span id="line-45"></span><span class="hs-comment">--</span><span>
</span><span id="line-46"></span><span class="hs-comment">-- * A 'String' that describes the error.</span><span>
</span><span id="line-47"></span><span class="hs-comment">--</span><span>
</span><span id="line-48"></span><span class="hs-comment">-- * The input value that caused the error.  If the error arose</span><span>
</span><span id="line-49"></span><span class="hs-comment">--   because the end of input was reached or could not be identified</span><span>
</span><span id="line-50"></span><span class="hs-comment">--   precisely, this value will be 'Nothing'.</span><span>
</span><span id="line-51"></span><span class="hs-comment">--</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- If the handler returns a value wrapped with 'Just', that value will</span><span>
</span><span id="line-53"></span><span class="hs-comment">-- be used in the output as the replacement for the invalid input.  If</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- it returns 'Nothing', no value will be used in the output.</span><span>
</span><span id="line-55"></span><span class="hs-comment">--</span><span>
</span><span id="line-56"></span><span class="hs-comment">-- Should the handler need to abort processing, it should use 'error'</span><span>
</span><span id="line-57"></span><span class="hs-comment">-- or 'throw' an exception (preferably a 'UnicodeException').  It may</span><span>
</span><span id="line-58"></span><span class="hs-comment">-- use the description provided to construct a more helpful error</span><span>
</span><span id="line-59"></span><span class="hs-comment">-- report.</span><span>
</span><span id="line-60"></span><span class="hs-keyword">type</span><span> </span><span id="OnError"><span class="annot"><a href="Data.Text.Encoding.Error.html#OnError"><span class="hs-identifier hs-var">OnError</span></a></span></span><span> </span><span id="local-6989586621679104119"><span class="annot"><a href="#local-6989586621679104119"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span id="local-6989586621679104118"><span class="annot"><a href="#local-6989586621679104118"><span class="hs-identifier hs-type">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104119"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104118"><span class="hs-identifier hs-type">b</span></a></span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="hs-comment">-- | A handler for a decoding error.</span><span>
</span><span id="line-63"></span><span class="hs-keyword">type</span><span> </span><span id="OnDecodeError"><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier hs-var">OnDecodeError</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnError"><span class="hs-identifier hs-type">OnError</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-comment">-- | A handler for an encoding error.</span><span>
</span><span id="line-66"></span><span class="hs-pragma">{-# DEPRECATED</span><span> </span><span class="hs-pragma">OnEncodeError</span><span> </span><span class="hs-pragma">&quot;This exception is never used in practice, and will be removed.&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-67"></span><span class="hs-keyword">type</span><span> </span><span id="OnEncodeError"><span class="annot"><a href="Data.Text.Encoding.Error.html#OnEncodeError"><span class="hs-identifier hs-var">OnEncodeError</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnError"><span class="hs-identifier hs-type">OnError</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-comment">-- | An exception type for representing Unicode encoding errors.</span><span>
</span><span id="line-70"></span><span class="hs-keyword">data</span><span> </span><span id="UnicodeException"><span class="annot"><a href="Data.Text.Encoding.Error.html#UnicodeException"><span class="hs-identifier hs-var">UnicodeException</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-71"></span><span>    </span><span id="DecodeError"><span class="annot"><a href="Data.Text.Encoding.Error.html#DecodeError"><span class="hs-identifier hs-var">DecodeError</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-72"></span><span>    </span><span class="hs-comment">-- ^ Could not decode a byte sequence because it was invalid under</span><span>
</span><span id="line-73"></span><span>    </span><span class="hs-comment">-- the given encoding, or ran out of input in mid-decode.</span><span>
</span><span id="line-74"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="EncodeError"><span class="annot"><a href="Data.Text.Encoding.Error.html#EncodeError"><span class="hs-identifier hs-var">EncodeError</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-75"></span><span>    </span><span class="hs-comment">-- ^ Tried to encode a character that could not be represented</span><span>
</span><span id="line-76"></span><span>    </span><span class="hs-comment">-- under the given encoding, or ran out of input in mid-encode.</span><span>
</span><span id="line-77"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679104104"><span id="local-6989586621679104114"><span class="annot"><span class="annottext">UnicodeException -&gt; UnicodeException -&gt; Bool
(UnicodeException -&gt; UnicodeException -&gt; Bool)
-&gt; (UnicodeException -&gt; UnicodeException -&gt; Bool)
-&gt; Eq UnicodeException
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: UnicodeException -&gt; UnicodeException -&gt; Bool
$c/= :: UnicodeException -&gt; UnicodeException -&gt; Bool
== :: UnicodeException -&gt; UnicodeException -&gt; Bool
$c== :: UnicodeException -&gt; UnicodeException -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></a></span></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-pragma">{-# DEPRECATED</span><span> </span><span class="hs-pragma">EncodeError</span><span> </span><span class="hs-pragma">&quot;This constructor is never used, and will be removed.&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="annot"><a href="Data.Text.Encoding.Error.html#showUnicodeException"><span class="hs-identifier hs-type">showUnicodeException</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#UnicodeException"><span class="hs-identifier hs-type">UnicodeException</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-82"></span><span id="showUnicodeException"><span class="annot"><span class="annottext">showUnicodeException :: UnicodeException -&gt; String
</span><a href="Data.Text.Encoding.Error.html#showUnicodeException"><span class="hs-identifier hs-var hs-var">showUnicodeException</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Encoding.Error.html#DecodeError"><span class="hs-identifier hs-type">DecodeError</span></a></span><span> </span><span id="local-6989586621679104099"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104099"><span class="hs-identifier hs-var">desc</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679104098"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679104098"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cannot decode byte '\\x&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; String -&gt; String
forall a. (Integral a, Show a) =&gt; a -&gt; String -&gt; String
</span><a href="../../base/src/Numeric.html#showHex"><span class="hs-identifier hs-var">showHex</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679104098"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;': &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104099"><span class="hs-identifier hs-var">desc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-84"></span><span class="annot"><a href="Data.Text.Encoding.Error.html#showUnicodeException"><span class="hs-identifier hs-var">showUnicodeException</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Encoding.Error.html#DecodeError"><span class="hs-identifier hs-type">DecodeError</span></a></span><span> </span><span id="local-6989586621679104097"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104097"><span class="hs-identifier hs-var">desc</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Word8
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cannot decode input: &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104097"><span class="hs-identifier hs-var">desc</span></a></span><span>
</span><span id="line-86"></span><span class="annot"><a href="Data.Text.Encoding.Error.html#showUnicodeException"><span class="hs-identifier hs-var">showUnicodeException</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Encoding.Error.html#EncodeError"><span class="hs-identifier hs-type">EncodeError</span></a></span><span> </span><span id="local-6989586621679104096"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104096"><span class="hs-identifier hs-var">desc</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679104095"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104095"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cannot encode character '\\x&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; String -&gt; String
forall a. (Integral a, Show a) =&gt; a -&gt; String -&gt; String
</span><a href="../../base/src/Numeric.html#showHex"><span class="hs-identifier hs-var">showHex</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Int
forall a. Enum a =&gt; a -&gt; Int
</span><a href="../../base/src/GHC.Enum.html#fromEnum"><span class="hs-identifier hs-var">fromEnum</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104095"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;': &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104096"><span class="hs-identifier hs-var">desc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span class="annot"><a href="Data.Text.Encoding.Error.html#showUnicodeException"><span class="hs-identifier hs-var">showUnicodeException</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Encoding.Error.html#EncodeError"><span class="hs-identifier hs-type">EncodeError</span></a></span><span> </span><span id="local-6989586621679104093"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104093"><span class="hs-identifier hs-var">desc</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Char
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cannot encode input: &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104093"><span class="hs-identifier hs-var">desc</span></a></span><span>
</span><span id="line-90"></span><span>
</span><span id="line-91"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679104088"><span id="local-6989586621679104091"><span class="annot"><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#UnicodeException"><span class="hs-identifier hs-type">UnicodeException</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-92"></span><span>    </span><span id="local-6989586621679104086"><span class="annot"><span class="annottext">show :: UnicodeException -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var hs-var hs-var hs-var">show</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnicodeException -&gt; String
</span><a href="Data.Text.Encoding.Error.html#showUnicodeException"><span class="hs-identifier hs-var">showUnicodeException</span></a></span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679104075"><span id="local-6989586621679104077"><span id="local-6989586621679104079"><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#Exception"><span class="hs-identifier hs-type">Exception</span></a></span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#UnicodeException"><span class="hs-identifier hs-type">UnicodeException</span></a></span></span></span></span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#NFData"><span class="hs-identifier hs-type">NFData</span></a></span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#UnicodeException"><span class="hs-identifier hs-type">UnicodeException</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-97"></span><span>    </span><span id="local-6989586621679104060"><span class="annot"><span class="annottext">rnf :: UnicodeException -&gt; ()
</span><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier hs-var hs-var hs-var hs-var">rnf</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Encoding.Error.html#DecodeError"><span class="hs-identifier hs-type">DecodeError</span></a></span><span> </span><span id="local-6989586621679104058"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104058"><span class="hs-identifier hs-var">desc</span></a></span></span><span> </span><span id="local-6989586621679104057"><span class="annot"><span class="annottext">Maybe Word8
</span><a href="#local-6989586621679104057"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; ()
forall a. NFData a =&gt; a -&gt; ()
</span><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier hs-var">rnf</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104058"><span class="hs-identifier hs-var">desc</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; () -&gt; ()
</span><a href="../../ghc-prim/src/GHC.Prim.html#seq"><span class="hs-operator hs-var">`seq`</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Word8 -&gt; ()
forall a. NFData a =&gt; a -&gt; ()
</span><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier hs-var">rnf</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Word8
</span><a href="#local-6989586621679104057"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; () -&gt; ()
</span><a href="../../ghc-prim/src/GHC.Prim.html#seq"><span class="hs-operator hs-var">`seq`</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span>    </span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier hs-var">rnf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Encoding.Error.html#EncodeError"><span class="hs-identifier hs-type">EncodeError</span></a></span><span> </span><span id="local-6989586621679104056"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104056"><span class="hs-identifier hs-var">desc</span></a></span></span><span> </span><span id="local-6989586621679104055"><span class="annot"><span class="annottext">Maybe Char
</span><a href="#local-6989586621679104055"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; ()
forall a. NFData a =&gt; a -&gt; ()
</span><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier hs-var">rnf</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104056"><span class="hs-identifier hs-var">desc</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; () -&gt; ()
</span><a href="../../ghc-prim/src/GHC.Prim.html#seq"><span class="hs-operator hs-var">`seq`</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Char -&gt; ()
forall a. NFData a =&gt; a -&gt; ()
</span><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier hs-var">rnf</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Char
</span><a href="#local-6989586621679104055"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; () -&gt; ()
</span><a href="../../ghc-prim/src/GHC.Prim.html#seq"><span class="hs-operator hs-var">`seq`</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span><span class="hs-comment">-- | Throw a 'UnicodeException' if decoding fails.</span><span>
</span><span id="line-101"></span><span class="annot"><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier hs-type">strictDecode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier hs-type">OnDecodeError</span></a></span><span>
</span><span id="line-102"></span><span id="strictDecode"><span class="annot"><span class="annottext">strictDecode :: OnDecodeError
</span><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier hs-var hs-var">strictDecode</span></a></span></span><span> </span><span id="local-6989586621679104054"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104054"><span class="hs-identifier hs-var">desc</span></a></span></span><span> </span><span id="local-6989586621679104053"><span class="annot"><span class="annottext">Maybe Word8
</span><a href="#local-6989586621679104053"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnicodeException -&gt; Maybe Char
forall a e. Exception e =&gt; e -&gt; a
</span><a href="../../base/src/GHC.Exception.html#throw"><span class="hs-identifier hs-var">throw</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Maybe Word8 -&gt; UnicodeException
</span><a href="Data.Text.Encoding.Error.html#DecodeError"><span class="hs-identifier hs-var">DecodeError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104054"><span class="hs-identifier hs-var">desc</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Word8
</span><a href="#local-6989586621679104053"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-comment">-- | Replace an invalid input byte with the Unicode replacement</span><span>
</span><span id="line-105"></span><span class="hs-comment">-- character U+FFFD.</span><span>
</span><span id="line-106"></span><span class="annot"><a href="Data.Text.Encoding.Error.html#lenientDecode"><span class="hs-identifier hs-type">lenientDecode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier hs-type">OnDecodeError</span></a></span><span>
</span><span id="line-107"></span><span id="lenientDecode"><span class="annot"><span class="annottext">lenientDecode :: OnDecodeError
</span><a href="Data.Text.Encoding.Error.html#lenientDecode"><span class="hs-identifier hs-var hs-var">lenientDecode</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Maybe Char
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\xfffd'</span></span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span class="hs-comment">-- | Throw a 'UnicodeException' if encoding fails.</span><span>
</span><span id="line-110"></span><span class="hs-pragma">{-# DEPRECATED</span><span> </span><span class="hs-pragma">strictEncode</span><span> </span><span class="hs-pragma">&quot;This function always throws an exception, and will be removed.&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-111"></span><span class="annot"><a href="Data.Text.Encoding.Error.html#strictEncode"><span class="hs-identifier hs-type">strictEncode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnEncodeError"><span class="hs-identifier hs-type">OnEncodeError</span></a></span><span>
</span><span id="line-112"></span><span id="strictEncode"><span class="annot"><span class="annottext">strictEncode :: OnEncodeError
</span><a href="Data.Text.Encoding.Error.html#strictEncode"><span class="hs-identifier hs-var hs-var">strictEncode</span></a></span></span><span> </span><span id="local-6989586621679104052"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104052"><span class="hs-identifier hs-var">desc</span></a></span></span><span> </span><span id="local-6989586621679104051"><span class="annot"><span class="annottext">Maybe Char
</span><a href="#local-6989586621679104051"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnicodeException -&gt; Maybe Word8
forall a e. Exception e =&gt; e -&gt; a
</span><a href="../../base/src/GHC.Exception.html#throw"><span class="hs-identifier hs-var">throw</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Maybe Char -&gt; UnicodeException
</span><a href="Data.Text.Encoding.Error.html#EncodeError"><span class="hs-identifier hs-var">EncodeError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104052"><span class="hs-identifier hs-var">desc</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Char
</span><a href="#local-6989586621679104051"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-113"></span><span>
</span><span id="line-114"></span><span class="hs-comment">-- | Ignore an invalid input, substituting nothing in the output.</span><span>
</span><span id="line-115"></span><span id="local-6989586621679104155"><span id="local-6989586621679104156"><span class="annot"><a href="Data.Text.Encoding.Error.html#ignore"><span class="hs-identifier hs-type">ignore</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnError"><span class="hs-identifier hs-type">OnError</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104156"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104155"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-116"></span><span id="ignore"><span class="annot"><span class="annottext">ignore :: forall a b. OnError a b
</span><a href="Data.Text.Encoding.Error.html#ignore"><span class="hs-identifier hs-var hs-var">ignore</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe b
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-117"></span><span>
</span><span id="line-118"></span><span class="hs-comment">-- | Replace an invalid input with a valid output.</span><span>
</span><span id="line-119"></span><span id="local-6989586621679104150"><span id="local-6989586621679104151"><span class="annot"><a href="Data.Text.Encoding.Error.html#replace"><span class="hs-identifier hs-type">replace</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679104151"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnError"><span class="hs-identifier hs-type">OnError</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104150"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104151"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-120"></span><span id="replace"><span class="annot"><span class="annottext">replace :: forall b a. b -&gt; OnError a b
</span><a href="Data.Text.Encoding.Error.html#replace"><span class="hs-identifier hs-var hs-var">replace</span></a></span></span><span> </span><span id="local-6989586621679104050"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679104050"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b -&gt; Maybe b
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679104050"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-121"></span></pre></body></html>